package fr.loof.fonzie;

import org.hibernate.proxy.AbstractLazyInitializer;
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.proxy.LazyInitializer;

class CarProxy
    extends Vehicle
    implements HibernateProxy
{
    private Car car;

    public CarProxy( Car car )
    {
        super( car.getId() );
        this.car = car;
    }

    public LazyInitializer getHibernateLazyInitializer()
    {
        LazyInitializer initializer = new AbstractLazyInitializer( "Car", car.getId(), null )
        {
            public Class getPersistentClass()
            {
                return Car.class;
            }
        };
        initializer.setImplementation( this.car );
        return initializer;
    }

    public Object writeReplace()
    {
        return car;
    }
}